<?php

namespace App\Traits\Relation;

use App\Models\AdminPrivilege;
use App\Models\PrivilegeStation;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

/**
 * 用于定义共派管理员账户和其他模型的关系
 *
 * @package App\Traits\Relation
 * Date: 2018/05/28
 * @author Tenny
 */
trait AdminUserRelation
{
    /**
     * 获取共派账户权限
     *
     * Date: 2018/06/08
     * @author Tenny
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function privileges()
    {
        return $this->belongsToMany(PrivilegeStation::class, 'station_privilege', 'admin_id', 'privilege_id', 'id', 'id')->withTimestamps();
    }
}
